﻿@inherits BaseComponentBase
@attribute [Authorize]
@attribute [IgnoreRolePermission]
@using Masa.Blazor.Presets
@using Microsoft.AspNetCore.Authorization;
@using ThingsGateway.Core.Extension
@namespace ThingsGateway.Admin.Blazor
@inject UserResoures UserResoures;
<MCard Rounded=true Elevation=1 Class="ma-2 pa-3">
    <div class="d-flex align-center justify-start ma-2">
        <MAvatar Size=40 Color="primary" Class="mx-2 white--text">
            @UserResoures.CurrentUser?.Account.GetNameLen2()
        </MAvatar>
        <MLabel Class="mx-3">@UserResoures.CurrentUser?.Account</MLabel>
        </div>
    </MCard>

    <MCard MinHeight=120 Rounded=true Elevation=1 Class="ma-2 mt-4">
        <MCardSubtitle Class="text-subtitle-1">
            @AppService.I18n.T("快捷方式")
    </MCardSubtitle>
    <MDivider></MDivider>
    <MRow Class="pa-4" NoGutters Align="AlignTypes.Center" Justify="JustifyTypes.Start">
         @foreach (var menu in UserResoures.UserWorkbenchOutputs ?? new())
        {
            <MButton Text Href=@menu.Href
                      Target=@((menu.MenuType == MenuTypeEnum.MENU || menu.MenuType == MenuTypeEnum.IFRAME) ? "_self" : "_blank") Class="ma-2 text-subtitle px-2">
                 <MIcon Left Size="30" Color="primary">@menu.Icon</MIcon>
                    @menu.Title
            </MButton>
        }
    </MRow>

</MCard>


<MRow NoGutters>
    <MCol Md=6 Cols="12">
        <MCard Style="height:500px;overflow-y:auto;overflow-x:hidden" Elevation=1 Rounded=true Class="ma-2">
            <MCardSubtitle Class="text-subtitle-1">
                @AppService.I18n.T("访问日志")
            </MCardSubtitle>
            <MDivider></MDivider>
            <MTimeline AlignTop Dense>
                @foreach (var item in _sysVisitLogs ?? new())
                {
                    <MTimelineItem Color="primary"
                                      Small>
                     <MRow Class="pt-1">
                         <MCol Cols="4">
                             <span class="text-caption">@item.OpTime.ToDefaultDateTimeFormat(AppService.TimezoneOffset)</span>
                            </MCol>
                            <MCol>
                                <div class="text-body-1">@item.Name</div>
                                <div class="text-caption">@item.OpIp</div>
                            </MCol>
                        </MRow>
                    </MTimelineItem>

                }

            </MTimeline>
        </MCard>
    </MCol>
    <MCol Md=6 Cols="12">
        <MCard Style="height:500px;overflow-y:auto;overflow-x:hidden" Elevation=1 Rounded=true Class="ma-2">
            <MCardSubtitle Class="text-subtitle-1">
                @AppService.I18n.T("操作日志")
            </MCardSubtitle>
            <MDivider></MDivider>
            <MTimeline AlignTop Dense>
                @foreach (var item in _sysOperateLogs ?? new())
                {
                    <MTimelineItem Color="primary"
                                      Small>
                     <MRow Class="pt-1">
                         <MCol Cols="4">
                             <span class="text-caption">@item.OpTime.ToDefaultDateTimeFormat(AppService.TimezoneOffset)</span>
                            </MCol>
                            <MCol>
                                <div class="text-body-1">@item.Name</div>
                                <div class="text-caption">@item.OpIp</div>
                            </MCol>
                        </MRow>
                    </MTimelineItem>

                }

            </MTimeline>
        </MCard>
    </MCol>
</MRow>


